<meta charset="UTF-8">
<style>
    *{
        padding: 0;
        margin: 0;
        font-size: 14px;
    }
    .bg{
        background: darkblue;
        height: 2000px;
    }
    #box{
        width: 500px;
        border:1px solid #ccc;
        padding: 10px;
        position: fixed;
        background: white;
        left:-1000px;
        transition: all .3s;
    }
    #closebtn{
        text-align: right;
    }
    #closebtn:hover{
        color: red;
    }
    .que{
        text-align: right;
    }
    .title{
        margin-bottom: 10px;
    }
    #confirmbtn{
        margin-right: 10px;
    }
    input{
        padding: 2px 10px;
    }
</style>
<input type="button" value="clickMe" id="clickbtn"/>
<div class="bg"></div>

<div id="mask"></div>

<div id="box">
    <div id="closebtn">×</div>
    <div class="title">标题</div>
    <div>行线的力量其实十分强大。大多数新手投资者都对基本的通道十分了解，但通道只是最基本的交易工具。但是合理利用平行线可以大大提高投资者识别市场关键点的能力。最简单的方法是首先确认支撑或阻力趋势线，一旦趋势线确认完成，沿著此线的上方或下方画一条平行线（通常是连接近期关键高点或低点），如此一来价格通道就基本确立。</div>
    <div class="que"><input type="button" value="确定" id="confirmbtn"/><input type="button" value="取消" id="quxiaobtn"/></div>
</div>

<script>
    mask.style.background = "rgba(0,0,0,.3)";
    mask.style.position = "absolute";
    var x = document.body.scrollWidth;
    var y = document.body.scrollHeight;
    mask.style.left = 0;
    mask.style.top = 0;
    mask.style.width = x;
    mask.style.height = y;
    mask.style.display = "none";

    quxiaobtn.onclick = closebtn.onclick = function(){
        box.style.left = "-1000px";
        mask.style.display = "none";
        setTimeout(function(){
            box.style.display = "none";
        },1000)
    }

    confirmbtn.onclick = function(){
        window.location = "new.html";
    }

    clickbtn.onclick = clickbtnf;
    function clickbtnf(){
        box.style.display = "block";
        var x = document.body.clientWidth;
        var y = document.body.clientHeight;
        var alertx =  box.clientWidth;
        var alerty = box.clientHeight;
        box.style.left = x/2 - alertx/2;
        box.style.top = y/2 - alerty/2;
        mask.style.display = "block";
    }
    window.onresize = function(){
        clickbtnf();
    }
</script>